#include "basicinterface.h"
#include "../GameEngine/minion.h"
#include "../GameEngine/engine.h"

BasicInterface::BasicInterface()
{
    MyMinion = nullptr;
}

BasicInterface::~BasicInterface() {}

void BasicInterface::SetMyMinion(Minion *SelectedMinion)
{
    MyMinion = SelectedMinion;
}

Minion *BasicInterface::GetMyMinion()
{
    return MyMinion;
}

void BasicInterface::NewOrder(double X, double Y)
{
    Minion *ClickedMinion = Engine::FindNearestMinion(X, Y);

    if(ClickedMinion != nullptr && ClickedMinion->GetTeam() != MyMinion->GetTeam() &&
            (ClickedMinion->IsStructure() ||
             Engine::IsVisible(ClickedMinion, MyMinion->GetTeam())))
    {
        MyMinion->NewTarget(ClickedMinion);
    }
    else
    {
        MyMinion->NewDestination(X, Y);
    }
}

void BasicInterface::GameStarted(int, QPair<int,int> const &)
{
}
